/// @tags:
#include <cstdio>
#include <functional>
#include <iostream>
#include <numeric>

using std::cin, std::cout, std::endl;

namespace BlueQuantum {

constexpr int maxn = 1e2 + 2;

int a[maxn], b[maxn];

int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, cnta = 0, cntb = 0;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
      cin >> a[i];
      if (a[i]) ++cnta;
    }
    for (int i = 1; i <= n; ++i) {
      cin >> b[i];
      if (b[i]) ++cntb;
    }
    if (cnta < cntb) {
      for (int i = 1; i <= n; ++i) {
        if (!b[i] && a[i]) {
          cout << cntb - cnta + 1 << endl;
          goto end;
        }
      }
      cout << cntb - cnta << endl;
    } else {
      for (int i = 1; i <= n; ++i) {
        if (b[i] && !a[i]) {
          cout << cnta - cntb + 1 << endl;
          goto end;
        }
      }
      cout << cnta - cntb << endl;
    }
  end:
    n = 0;
  }
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("A. Make A Equal to B.in", "r", stdin);
  freopen("A. Make A Equal to B.out", "w", stdout);
#endif
#endif

  std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
